package com.syxp.pda.action.standard;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.syxp.pda.core.web.action.BaseAction;
import com.syxp.pda.entity.standard.CHKMeans;
import com.syxp.pda.service.standard.CHKMeansService;

public class CHKMeansAction extends BaseAction {
	@Resource
	private CHKMeansService chkMeansService;
	
	private int chkMeansID;
	private CHKMeans chkmeans;
	
	public String load() {
		List list = new ArrayList(); 
		try {
			List<CHKMeans> chkmeans = this.chkMeansService.getDao().getAll();
			for(CHKMeans o: chkmeans) {
				Map map = new HashMap();
				map.put("chkMeansName", o.getChkMeans());
				map.put("chkMeansID", o.getChkMeansID());
				list.add(map);
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
		this.jsonString = this.gson.toJson(list);
		System.out.println(this.jsonString);
		return SUCCESS;
	}
	
	public String save() {
		try {
			this.chkMeansService.addService(this.chkmeans);
			this.jsonString="{success:true}" ;
		} catch(Exception e) {
			e.printStackTrace();
			this.jsonString="{success:false}" ;
		}
		return SUCCESS;
	}
	
	public String delete() {
		try {
			this.chkMeansService.removeService(this.chkMeansID);
			this.jsonString="{success:true}" ;
		} catch(Exception e) {
			e.printStackTrace();
			this.jsonString="{success:false}" ;
		}
		return SUCCESS;
	}
	
	public String update() {
		try {
			this.chkMeansService.updateService(this.chkmeans);
			this.jsonString="{success:true}" ;
		} catch(Exception e) {
			e.printStackTrace();
			this.jsonString="{success:false}" ;
		}
		return SUCCESS;
	}

	/**
	 * @return the chkMeansService
	 */
	public CHKMeansService getChkMeansService() {
		return chkMeansService;
	}

	/**
	 * @param chkMeansService the chkMeansService to set
	 */
	public void setChkMeansService(CHKMeansService chkMeansService) {
		this.chkMeansService = chkMeansService;
	}

	/**
	 * @return the chkMeansID
	 */
	public int getChkMeansID() {
		return chkMeansID;
	}

	/**
	 * @param chkMeansID the chkMeansID to set
	 */
	public void setChkMeansID(int chkMeansID) {
		this.chkMeansID = chkMeansID;
	}

	/**
	 * @return the chkmeans
	 */
	public CHKMeans getChkmeans() {
		return chkmeans;
	}

	/**
	 * @param chkmeans the chkmeans to set
	 */
	public void setChkmeans(CHKMeans chkmeans) {
		this.chkmeans = chkmeans;
	}


}
